package com.creative.accountsdk.net.account;

import com.creative.accountsdk.UmsChannel;
import com.creative.accountsdk.UserData;
import com.creative.accountsdk.net.Protocol;
import com.creative.accountsdk.net.XParams;
import com.loopj.android.http.RequestParams;

import org.json.JSONArray;
import org.json.JSONObject;

/**
 * Created by wang_qian on 2015/11/28.
 */
public class ParentBindChildProtocol  extends Protocol {
    private String childInviteCode;
    private UserData userData;
    public JSONArray kidsJsonArray;

    public  ParentBindChildProtocol(String inviteCode) {
        childInviteCode = inviteCode;
        userData = UserData.getInstance();
    }


    @Override
    public RequestParams getParams() {
        return new XParams()
                .put("uid", userData.getUid())
                .put("qrcode",childInviteCode)
                .put(UmsChannel.PARAM_NAME, UmsChannel.getChannel())
                .getParams();
    }

    @Override
    public String getUrl() {
        return getUrlPrefix()+"ui/bind/kid";
    }

    @Override
    protected void parseReturnMap(JSONObject returnMap) {
          if (returnMap.has("kids")) {
              kidsJsonArray = returnMap.optJSONArray("kids");
          }
    }
}
